home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / doors / sysup / desc.c next >
Encoding:
C/C++ Source or Header  |  1992-12-26  |  4.5 KB  |  174 lines

  1. /*#include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <dos/dos.h>
  4. #include <stdio.h>*/
  5. #include "functions.h"
  6. #include "defines.h"
  7. extern UBYTE GSTR1[1024],GSTR2[1024],GSTR3[1024];
  8. extern long Time_system;
  9. extern int Whence_The_Logon;
  10. extern long fsize;
  11. extern struct Commands Cmds;
  12. extern struct User User;
  13.  
  14. char PurgeScanNM[31];
  15. void PurgeScanName();
  16. int GetHoldDesc(char *FileName,int Conf)
  17. {
  18. struct FileInfoBlock *FBlock;
  19. BPTR FLock;
  20.    FILE *fi;
  21.    char str[200];
  22.    char Istr[200];
  23.    char fmtstr[200];
  24.    char temp[80],str2[255];
  25.    char odate[20],fcomment[70],scomment[9][50];
  26.    int status;
  27.    int x2,cstat;
  28.    int dirnum;
  29.    int Exists=0;
  30.    strcpy(str,FileName);
  31.             
  32.                 sm("",1);sm("Please enter a description, you have eight lines for your description.",1);
  33.                 sm("",1);sm("Press return alone to end.",1);
  34.                 sm("                                [--------------------------------------------]",1);
  35.                 sprintf(fmtstr,"%-13s %7ld  %s :",str,fsize,odate);
  36.                 AEPutStr(fmtstr);
  37.                     sprintf(fmtstr,"%-13sP%7ld  %s  ",str,fsize,odate);
  38.                 status=LineInput("",fcomment,44,KEYBOARD_TIMEOUT);
  39.                 if(status<0) { DropDTR(); return(0); }
  40.                 if(strlen(fcomment)==0) { goto CINPAgain; }
  41.                     strcat(fmtstr,fcomment); strcpy(fcomment,fmtstr);
  42.                 x2=0;
  43.                                  do
  44.                     {
  45.                     AEPutStr("                                :");
  46.                     status=LineInput("",scomment[x2],44,KEYBOARD_TIMEOUT);
  47.                     if(status<0) { DropDTR(); return(0); }
  48.                     x2+=1;
  49.                     } while(strlen(scomment[x2-1])!=0&&x2<7);
  50.  if(fcomment[33]=='/')
  51.  sprintf(Istr,"%sHOLD/%s",Cmds.ConfLoc[Conf],str);
  52.  else
  53.  sprintf(Istr,"%sUpload/%s",Cmds.ConfLoc[Conf],str);
  54.  
  55.    sprintf(fmtstr,"%sLCFILES/%s",Cmds.ConfLoc[Conf],str);
  56.    fi=fopen(Istr,"rb");
  57.    if(fi==NULL)
  58.    {
  59.      rename(fmtstr,Istr);
  60.      sprintf(str,"touch %s",Istr); Execute(str,NULL,NULL);
  61.      sprintf(fmtstr,"%sndirs",Cmds.ConfLoc[Conf]);
  62.      fi=fopen(fmtstr,"r");
  63.      if(fi==NULL) return(1);
  64.      fgets(fmtstr,80,fi);
  65.      dirnum=atoi(fmtstr);
  66.      fclose(fi);
  67.      if(fcomment[33]=='/')
  68.      sprintf(fmtstr,"%sHold/Held",Cmds.ConfLoc[Conf]);
  69.      else
  70.      sprintf(fmtstr,"%sdir%d",Cmds.ConfLoc[Conf],dirnum);
  71.    }
  72.    else
  73.    { Exists=1; AEPutStr("Sorry but this Upload already exists!\r\n");
  74.      unlink(fmtstr);
  75.      fclose(fi);
  76.    }
  77.  
  78.  if(!Exists)
  79.  {
  80.    fi=fopen(fmtstr,"a");
  81.    if(fi==NULL) return(1);
  82.    dirnum=0;
  83.    fprintf(fi,"%s\n",fcomment);
  84.    while(dirnum<x2-1)
  85.    {
  86.      fprintf(fi,"                                 %s\n",scomment[dirnum]);
  87.      dirnum++;
  88.    }
  89. if(Cmds.AcLvl[20]>0)
  90.         {
  91.           fprintf(fi,"                                 Sent by: %s\n",User.Name);
  92.         }
  93.    fclose(fi);
  94.    User.Bytes_Upload += fsize;
  95.    User.Uploads +=1;
  96.    if(fcomment[33]!='/')
  97.    return(2); else return(3);
  98.   }else return(4);
  99. }
  100.  
  101. void ScanHoldDesc(void)
  102. {
  103.   FILE *fi;
  104.   char string[200];
  105.   char Temp[200];
  106.   char Text[200];
  107.   register int i;
  108.   int Result;
  109.   PurgeScanName();
  110.   sprintf(Text,"LOSS CARRIER %s",User.Name);strupr(Text);
  111.   AEPutStr("Searching for LOSS CARRIER Files!\r\n");
  112.   for(i=0;i<9;i++)
  113.   {
  114.    
  115.     if(Cmds.ConfLoc[i]!='\0')
  116.     {  
  117.        sprintf(string,"%sLCFILES/%s.lc",Cmds.ConfLoc[i],PurgeScanNM);
  118.        
  119.        fi=fopen(string,"r");
  120.        if(fi!=NULL)
  121.        {
  122.          while(fgets(string,80,fi)!=NULL)
  123.          {
  124.            StripReturn(string);
  125.            strcpy(Temp,string);
  126.            strupr(&string[33]);
  127.            if(!strcmp(Text,&string[33]))
  128.            {
  129.              
  130.              string[12]='\0';
  131.              StripReturn(string);
  132.              Result=GetHoldDesc(string,i);
  133.              if(Result==0) { fclose(fi); return;}
  134.              if(Result==3)
  135.              { 
  136.                AEPutStr("Moving ");AEPutStr(string);AEPutStr(" to Sysop Hold\r\n");
  137.              }
  138.              if(Result==2)
  139.              {
  140.                AEPutStr("Moving ");AEPutStr(string);AEPutStr(" to Download Path\r\n");
  141.              }
  142.              if(Result==4)
  143.              {
  144.                AEPutStr("Deleting ");AEPutStr(string);AEPutStr("\r\n");
  145.              }
  146.              
  147.            }
  148.           }
  149.           sprintf(string,"%sLCFILES/%s.lc",Cmds.ConfLoc[i],PurgeScanNM);
  150.           fclose(fi); unlink(string);
  151.          }
  152.       
  153.       }
  154.     }
  155.     AEPutStr("\r\n");
  156.     
  157. }
  158.  
  159. void PurgeScanName()
  160. {
  161.    char st[31];
  162.    register int i,j;
  163.    strcpy(st,User.Name);
  164.    i=strlen(st);
  165.    j=0;
  166.    while(j<i)
  167.    {
  168.      if((st[j]>='A' && st[j]<='Z') || (st[j]>='a' && st[j]<='z'))
  169.      { j++; continue;}
  170.      if(st[j]!=0)st[j]='_';
  171.      j++;
  172.    }
  173.    sprintf(PurgeScanNM,"%.27s",st);
  174. }